<?php

/**
 * tpshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.tp-shop.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: 当燃 2016-01-09
 */

namespace Mobile\Controller;

class IndexController extends MobileBaseController {

    
    public function index() {

        header("Location: ".U('Mobile/User/Index'));
        /*$hot_goods = M('goods')->where("is_hot=1 and is_on_sale=1")->order('goods_id DESC')->limit(20)->cache(true, TPSHOP_CACHE_TIME)->select(); //首页热卖商品
        $thems = M('goods_category')->where('level=1')->order('sort_order')->limit(9)->cache(true, TPSHOP_CACHE_TIME)->select();
        $this->assign('thems', $thems);
        $this->assign('hot_goods', $hot_goods);
        $favourite_goods = M('goods')->where("is_recommend=1 and is_on_sale=1")->order('goods_id DESC')->limit(20)->cache(true, TPSHOP_CACHE_TIME)->select(); //首页推荐商品
        $this->assign('favourite_goods', $favourite_goods);
        $this->display();*/
    }

    /**
     * 分类列表显示
     */
    public function categoryList() {
        $this->display();
    }

    /**
     * 模板列表
     */
    public function mobanlist() {
        $arr = glob("D:/wamp/www/svn_tpshop/mobile--html/*.html");
        foreach ($arr as $key => $val) {
            $html = end(explode('/', $val));
            echo "<a href='http://www.php.com/svn_tpshop/mobile--html/{$html}' target='_blank'>{$html}</a> <br/>";
        }
    }

    /**
     * 商品列表页
     */
    public function goodsList() {
        $goodsLogic = new \Home\Logic\GoodsLogic(); // 前台商品操作逻辑类
        $id = I('get.id', 0); // 当前分类id
        $lists = getCatGrandson($id);
        $this->assign('lists', $lists);
        $this->display();
    }

    public function ajaxGetMore() {
        $p = I('p', 1);
        $favourite_goods = M('goods')->where("is_recommend=1 and is_on_sale=1")->order('goods_id DESC')->page($p, 10)->cache(true, TPSHOP_CACHE_TIME)->select(); //首页推荐商品
        $this->assign('favourite_goods', $favourite_goods);
        $this->display();
    }

}
